##############################################################
#Figure 7: Hurricane Proximity Makes Individuals Choose Riskier Gambles 
##############################################################

data <- read.dta13("U:/temp/coefplot_risk.dta")

keep <- c("var","treatment4000", "treatment3000","treatment2000", "treatment1000", "treatment500",
          "treatment400", "treatment300")

data <- data[keep]


newdf <- data %>%
  gather(variable, value, -var) %>%
  spread(var, value)


newdf$id <- c(4,3,7,2,6,1,5) 

ggplot () + 
  geom_pointrange(data=newdf, mapping = aes(x=as.factor(id), y=coef, ymin=ci_upper, ymax=ci_lower),
                  size=1.2, fatten = 2, shape=21, fill="goldenrod1", color="grey") + 
  geom_ribbon(data=newdf, mapping = aes(x=id, ymin=ci_upper, ymax=ci_lower), alpha=.05) +
  geom_hline(yintercept = 0, col="grey", lwd=1,lty="dashed") + xlab("Distance Band") + 
  ylab("Effect on Risk Aversion") + 
  scale_x_discrete(limit=c("1", "2","3","4","5","6","7"),
                   labels=c("[4000,30)","[3000,30)","[2000,30)","[1000,30)",
                            "[500,30)","[400,30)","[300,30)")) + 
  ylim(-.35,.15)

ggsave("U:/export/fig7.pdf")
